package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dao.RoomConditionDao;
import pojo.Manager;
import server.LoginServer;

public class LoginServlet extends HttpServlet {
	public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		String num = request.getParameter("num");
		String pw = request.getParameter("password");
		if(num == null || pw == null){
			System.out.println("num||pw=null");
			response.sendRedirect("/hotel/login.jsp");
		}
		System.out.println(num);
		System.out.println(pw);
		LoginServer loginServer = new LoginServer();
		Manager manager = loginServer.judgeLogin(num, pw);
		HttpSession session = request.getSession();
		
		if(manager != null){
			System.out.println("succeed");
			session.setAttribute("massage", "succeed");
			session.setAttribute("inof",manager);
//			RoomConditionDao roomCondition = new RoomConditionDao();
//			List<String> list = roomCondition.selectRoomCondidion();
			response.sendRedirect("/hotel/menu.jsp");
		}
		else{
			session.setAttribute("massage","error");
			response.sendRedirect("/hotel/login.jsp");
		}
	}
}
